<?php

namespace App\Http\Controllers\Admin;

use App\Models\Notice;
use Illuminate\Http\Request;

class NoticeController extends BaseController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        if($request->wantsJson()){
            $where =[];
            $title = $request->input('title');
            if($title){
                $where =[['title', 'like', "%{$request->input('title')}%"]];
            }
            $data  = $this->getPage('notices',$where);
            return response()->json($data);
        }
        return view("admin.notice.index");
    }

    /**
     *
     *添加 预约
     */
    public function create()
    {
       return view('admin.notice.create');
    }

    /**
     * 添加
     */
    public function store(Request $request)
    {
        $this->validate($request,[
            'cnt'=>'required'
        ]);
        $re = Notice::create($request->only('fd_id','us_id','cnt','detime'));
        if($re){
            return $this->reSuJson('成功');
        }
        return $this->reErJson('失败');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function show(Notice $notice)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function edit(Notice $notice)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Notice $notice)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function destroy(Notice $notice)
    {
        //
    }
}
